import { strict as assert } from 'node:assert';
import { By, until } from 'selenium-webdriver';
import { describe, it, before, after } from 'mocha';
import { createDriver, BASE_URL, ensureServerUp } from './setup.mjs';
import { login } from './common.mjs';

describe('我的收藏页面 E2E', function () {
  this.timeout(60000);
  let driver;

  before(async function () {
    await ensureServerUp(60000);
    driver = await createDriver();
    await driver.manage().setTimeouts({
      implicit: 0,
      pageLoad: 60000,
      script: 30000
    });
    await login(driver);
  });

  after(async function () {
    if (driver) {
      await driver.quit();
    }
  });

  it('应加载我的收藏页面', async function () {
    await driver.get(`${BASE_URL}/favorites`);
    await driver.sleep(2000);
    const content = await driver.getPageSource();
    assert.ok(content.length > 0, '我的收藏页面应加载');
  });
});

